package com.neusoft.elmboot.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.elmboot.po.Integrationlog;
import com.neusoft.elmboot.service.IntegrationlogService;

@RestController
@RequestMapping("/IntegrationlogController")
@CrossOrigin
public class IntegrationlogController {

    @Autowired
    IntegrationlogService integrationlogService;
    //  某个用户增加count分
    @RequestMapping("/saveIntegrationlogByPay")
    public int saveIntegrationlogByPay(Integrationlog il, Integer count) throws Exception {
    	for(int i = 1; i <= count; i++) {
    		integrationlogService.saveIntegrationlogByPay(il);
    	}
        return count;
    }
    //  查询当前时刻某用户的所有有效积分
    @RequestMapping("/getIntegrationlogByUserIdByTime")
    public int getIntegrationlogByUserIdByTime(String userId) throws Exception {
        return integrationlogService.getIntegrationlogByUserIdByTime(userId);
    }
    //  某个用户用掉count分
    @RequestMapping("/deleteIntegrationlogByUserIdByTime")
    public int deleteIntegrationlogByUserIdByTime(String userId, Integer count) throws Exception {
    	return integrationlogService.deleteIntegrationlogByUserIdByTime(userId,count);
    }
    //  删去某个用户已过期的积分
    @RequestMapping("/updateIntegrationlog")
    public int updateIntegrationlog(String userId) throws Exception {
    	return integrationlogService.updateIntegrationlog(userId);
    }
    
    @RequestMapping("/getExpirationIntegrationlogByUserId")
    public int getExpirationIntegrationlogByUserId(String userId) throws Exception {
    	return integrationlogService.getExpirationIntegrationlogByUserId(userId);
    }
}
